#include <unistd.h>

#include "include/state.hpp"

int main( int argc, char *argv[] )
{
	int c, ret;
	verbosity logging;
	std::string configfile = getenv("HOME");
	
	// set default config file path
	configfile = configfile + PATH_DELIM + CONFIG_FILENAME;
	
	// set default logging verbosity
	logging = LOG_GENERAL;
	
	while ((c = getopt (argc, argv, "qvd")) != -1 )
	{
		switch(c)
		{
			case 'q':
			logging = LOG_QUIET;
			break;
			
			case 'v':
			logging = LOG_VERBOSE;
			break;
			
			case 'd':
			logging = LOG_DEBUG;
			break;
			
		}
	}
	
	// set up
	State *s = new State( logging, configfile.c_str() );
	
	// run
	if (s->initialized) s->run();
	
	delete s;
	
	// clean up
	
	return ret;
}